﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JBeamLibrary.VehicleParts.Collections
{
    public class InputSourceScaleCollection : DictionaryBase
    {
        #region Indexers

        /// <summary>Gets the multiply value for the given input source</summary>
        /// <param name="inputSource"></param>
        /// <returns></returns>
        public float this[string inputSource]
        {
            get { return (float) Dictionary[inputSource]; }
        }

        #endregion

        #region CTORs

        public InputSourceScaleCollection()
        {
            
        }

        #endregion

        #region Methods

        public bool Add(string inputSource, float scale)
        {
            if (Dictionary.Contains(inputSource)) return false;
            Dictionary.Add(inputSource, scale);
            return true;
        }

        public void UpdateAdd(string inputSource, float scale)
        {
            if (!Add(inputSource, scale))
                Dictionary[inputSource] = scale;
        }

        public void AddRange(IEnumerable<KeyValuePair<string, float>> inputSourceScales)
        {
            foreach (var pair in inputSourceScales)
                Add(pair.Key, pair.Value);
        }

        public void UpdateAddRange(IEnumerable<KeyValuePair<string, float>> inputSourceScales)
        {
            foreach (var pair in inputSourceScales)
                UpdateAdd(pair.Key, pair.Value);
        }

        public bool Remove(string inputSource)
        {
            if (!Dictionary.Contains(inputSource)) return false;
            Dictionary.Remove(inputSource);
            return true;
        }

        #endregion
    }
}
